<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ page isELIgnored="false"%>
<!DOCTYPE html>
<html lang="en">
<head>
<jsp:include page="header.jsp" />
</head>

<body>

	<jsp:include page="menue.jsp">
		<jsp:param value="./types" name="active" />
	</jsp:include>

	<div class="container">

		<h1>Profiltypen</h1>
		<p>
			Use this document as a way to quick start any new project.<br>
			All you get is this message and a barebones HTML document.
		</p>
		<br />
		<c:choose>
			<c:when test="${not empty entities}">
				<form action="./types" method="post">
					<button class="btn btn-primary" type="submit" name="new">Neuer
						Profiltyp</button>
				</form>
				<div class="row">
					<div class="span12">
						<table class="table table-striped table-bordered table-condensed">
							<thead>
								<tr>
									<th>#</th>
									<th class="blue">Artikelnummer</th>
									<th class="blue">Name</th>
									<th class="blue">Serie</th>
									<th class="blue">Standard Lagerort</th>
									<th class="blue">ID</th>
									<th class="blue">Aktion</th>
								</tr>
							</thead>
							<tbody>
								<c:forEach var="entity" items="${entities}" varStatus="status">
									<tr>
										<td>${status.count}</td>
										<td>${entity.articleNumber}</td>
										<td>${entity.name}</td>
										<td>${entity.series.name}</td>
										<td>${entity.shelf.name}</td>
										<td>${entity.id}</td>

										<td>
											<form action="./types" method="post">
												<input type="hidden" name="entityId" value="${entity.id}">
												<button name="edit" type="submit" class="btn btn-primary">
													<i class="icon-pencil icon-white"></i> Bearbeiten
												</button>

												<div id="deleteDialog${entity.id}" class="modal hide fade">
													<div class="modal-header">
														<a class="close" data-dismiss="modal">&times;</a>
														<h3>L&ouml;schen best&auml;tigen</h3>
													</div>
													<div class="modal-body">
														<h4>Profiltyp ${entity.articleNumber} l&ouml;schen</h4>
														<br />
														<p>Sind Sie sicher, dass Sie den Profiltypen ${entity.articleNumber}
															unwiderruflich l&ouml;schen m&ouml;chten ?</p>
													</div>
													<div class="modal-footer">
														<button name="delete" type="submit" class="btn btn-danger">
															<i class="icon-trash icon-white"></i>L&ouml;schen
															best&auml;tigen
														</button>
														<a href="#" class="btn" data-dismiss="modal">Abbrechen</a>
													</div>
												</div>
												<a data-toggle="modal" href="#deleteDialog${entity.id}"
													class="btn btn-danger"><i class="icon-trash icon-white"></i>
													L&ouml;schen</a>
											</form>
										</td>
									</tr>
								</c:forEach>
							</tbody>
						</table>
					</div>
				</div>
				<!-- /row -->
			</c:when>
			<c:otherwise>
				<div class="row">
					<div class="span8">
						<form id="detailForm" class="form-horizontal" action="./types"
							method="post">
							<fieldset>
								<c:choose>
									<c:when test="${not empty entity.id}">
										<legend>Profiltyp ${entity.articleNumber} bearbeiten</legend>
									</c:when>
									<c:otherwise>
										<legend>Einen neuen Profiltyp anlegen</legend>
									</c:otherwise>
								</c:choose>
								<div id="articleNumberGroup" class="control-group">
									<label class="control-label" for="articleNumber">Artikelnummer</label>
									<div class="controls">
										<input id="articleNumber" name="articleNumber" size="16"
											type="text" value="${entity.articleNumber}"> <span
											id="articleNumberError" class="help-inline">Bitte
											geben Sie eine Artikelnummer an!</span>
										<p class="help-block">Here's more help text</p>
									</div>
								</div>
								<div id="typeNameGroup" class="control-group">
									<label class="control-label" for="typeName">Name</label>
									<div class="controls">
										<input id="typeName" name="name" size="16" type="text"
											value="${entity.name}"> <span id="typeNameError"
											class="help-inline">Bitte geben Sie einen Namen an!</span>
										<p class="help-block">Here's more help text</p>
									</div>
								</div>
								<div class="control-group">
									<label class="control-label" for="series">Serie</label>
									<div class="controls">
										<select id="series" name="seriesId">
											<c:forEach var="seriesItem" items="${series}">
												<option value="${seriesItem.id}">${seriesItem.name}</option>
											</c:forEach>
										</select>
									</div>
								</div>
								<div class="control-group">
									<label class="control-label" for="shelf">Standard
										Lagerort</label>
									<div class="controls">
										<select id="shelf" name="shelfId">
											<c:forEach var="shelf" items="${shelves}">
												<option value="${shelf.id}">${shelf.number} -
													${shelf.name}</option>
											</c:forEach>
										</select>
									</div>
								</div>
								<div id="errorMessage" class="alert alert-error">Bitte
									&uuml;berpr&uuml;fen Sie Ihre Eingabe!</div>
								<div class="form-actions">
									<input type="hidden" name="entityId" value="${entity.id}" />
									<a href="./types" class="btn">Abbrechen</a>
									<c:choose>
										<c:when test="${not empty entity.id}">
											<button type="submit" name="save" class="btn btn-primary">Speichern</button>
										</c:when>
										<c:otherwise>
											<button type="submit" name="save" class="btn btn-primary">Anlegen</button>
										</c:otherwise>
									</c:choose>
								</div>
							</fieldset>
						</form>
					</div>
				</div>
			</c:otherwise>
		</c:choose>
	</div>
	<!-- /container -->
	<jsp:include page="includes.jsp" />

</body>
</html>